package de.fhd.pms.dao;

import java.util.List;

import java.util.Set;

import org.springframework.beans.propertyeditors.CustomCollectionEditor;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import de.fhd.pms.model.Action;
import de.fhd.pms.model.User;

/**
 * The Data access class for Actions. All Interaction with the database
 * regarding the entity bean Action should be handled by this class!
 *
 */

public class ActionDao extends HibernateDaoSupport {
	
	/** Set ActionDao
	 @param userDao */
	public void setUserDao(UserDao userDao) {
	}
	
	/**Get UserDao
	 @return userDao
	  */
	public UserDao getUserDao() {
		return null;
	}
	
	/**
	 <p>Returns a single {@link Action} by its primary db key</p>
	 * @param action_id
	 * @return a single {@link Action}
	 */
	public Action findByActionId(int action_id) {
		HibernateTemplate template = getHibernateTemplate();
		return (Action) template.get(Action.class, action_id);
	}
	
	/**
	 * <p>Returns all Actions from the database.</p>
	 * @return a list of Actions
	 * @see Action
	 */
	public List<Action> findAll() {
		HibernateTemplate template = getHibernateTemplate();
		return template.loadAll(Action.class);
	}
	
	/**
	 * <p>Creates a new {@link Action} and saves it in the database.</p>
	 * @param action a {@link Action} object that should be saved in the db.
	 * @return the object {@link Action} specified by the parameter.
	 * 
	 */
	public Action save(Action action) {
		HibernateTemplate template = getHibernateTemplate();
		template.saveOrUpdate(action);
		return action;
	}
	
	/**
	 * <p>Deletes a {@link Action} from the database.</p>
	 * @param action a {@link Action} object that should be deleted in the db.
	 * 
	 */
	public void delete(Action action) {
		HibernateTemplate template = getHibernateTemplate();
		template.delete(action);
	}

}
